import Common
from selenium.webdriver.common.by import By

def test_01_normal_user_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (
        username, username, encryptPassword, Common.generateRandomNumber(18),
        Common.generateRandomNumber(11),
        Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    Common.login(self.Driver, username, password)
    navbarBrand = self.Driver.find_element(By.CLASS_NAME, "navbar-brand").text
    if target == navbarBrand:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, navbarBrand)

def test_02_normal_admin_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    admin = (username, encryptPassword, 0)
    Common.getAdminIfNotExistAddAdmin(self.db, self.cursor, username, encryptPassword, admin)
    Common.login(self.Driver, username, password)
    navbarBrand = self.Driver.find_element(By.CLASS_NAME, "navbar-brand").text
    if target == navbarBrand:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, navbarBrand)
def test_03_normal_user_special_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor,password)
    user = (username, username, encryptPassword,Common.generateRandomNumber(18),Common.generateRandomNumber(11),Common.getRandomEmail(),666666, 0,"良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor,username, encryptPassword, user)
    Common.login(self.Driver, username, password)
    navbarBrand = self.Driver.find_element(By.CLASS_NAME, "navbar-brand").text
    if target==navbarBrand:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, navbarBrand)

def test_04_normal_user_errorUsername_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    username2 = Common.judgeIsNone(values["username2"])
    password2 = Common.judgeIsNone(values["password2"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword=Common.getEncryptPassword(self.db,self.cursor,password)
    user = (username, username, encryptPassword,Common.generateRandomNumber(18),Common.generateRandomNumber(11),Common.getRandomEmail(),666666, 0,"良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor,username, encryptPassword, user)
    Common.ifExistUsernameDelUser(self.db,self.cursor,username2)
    Common.login(self.Driver, username2, password2)
    helpBlock = self.Driver.find_element(By.CLASS_NAME, "help-block").text
    if target==helpBlock:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, helpBlock)
# 普通用户-错误用户名登陆-校验不存在账户登陆
def test_05_normal_user_errorPassword_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    username2 = Common.judgeIsNone(values["username2"])
    password2 = Common.judgeIsNone(values["password2"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword=Common.getEncryptPassword(self.db,self.cursor,password)
    user = (username, username, encryptPassword,Common.generateRandomNumber(18),Common.generateRandomNumber(11),Common.getRandomEmail(),666666, 0,"良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor,username, encryptPassword, user)
    Common.ifExistUsernamePasswordDelUser(self.db,self.cursor,username2,password2)
    Common.login(self.Driver, username2, password2)
    helpBlock = self.Driver.find_elements(By.CLASS_NAME, "help-block")[1].text
    if target==helpBlock:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, helpBlock)
#管理员用户-错误用户名登陆-校验不存在账户登陆
def test_06_normal_admin_errorUsername_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    username2 = Common.judgeIsNone(values["username2"])
    password2 = Common.judgeIsNone(values["password2"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword=Common.getEncryptPassword(self.db,self.cursor,password)
    admin = (username, encryptPassword, 0)
    Common.getAdminIfNotExistAddAdmin(self.db,self.cursor,username, encryptPassword, admin)
    Common.ifExistUsernameDelAdmin(self.db,self.cursor,username2)
    Common.login(self.Driver, username2, password2)
    helpBlock = self.Driver.find_element(By.CLASS_NAME, "help-block").text
    if target==helpBlock:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, helpBlock)

#管理员用户-错误密码登陆-校验密码错误账户登陆
def test_07_normal_admin_errorPassword_login(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    username2 = Common.judgeIsNone(values["username2"])
    password2 = Common.judgeIsNone(values["password2"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword=Common.getEncryptPassword(self.db,self.cursor,password)
    admin = (username, encryptPassword, 0)
    Common.getAdminIfNotExistAddAdmin(self.db,self.cursor,username, encryptPassword, admin)
    Common.ifExistUsernamePasswordDelAdmin(self.db,self.cursor,username2, password2)
    Common.login(self.Driver, username2, password2)
    helpBlock = self.Driver.find_elements(By.CLASS_NAME, "help-block")[1].text
    if target==helpBlock:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, helpBlock)
# 正常用户注册-成功测试
def test_01_normal_user_register(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    repassword = Common.judgeIsNone(values["repassword"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword=Common.getEncryptPassword(self.db,self.cursor,password)
    Common.ifExistUsernameDelUser(self.db,self.cursor, username)
    Common.register(self.Driver, username, password, repassword)
    sqltarget=Common.getUserCount(self.db,self.cursor,username,encryptPassword)
    sqltarget = str(sqltarget)
    if target==sqltarget:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, sqltarget)
#重复用户注册-失败测试
def test_02_normal_user_again_register(self, values,writeList,index):
    username=Common.judgeIsNone(values["username"])
    password=Common.judgeIsNone(values["password"])
    repassword=Common.judgeIsNone(values["repassword"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor,username, encryptPassword, user)
    Common.register(self.Driver, username, password, repassword)
    sqltarget = Common.getUserCount(self.db,self.cursor, username, encryptPassword)
    sqltarget = str(sqltarget)
    if target==sqltarget:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target,sqltarget)
#密码与确认密码不相同测试
def test_03_normal_user_passwordNotEqualRepassword_register(self, values,writeList,index):
    username=Common.judgeIsNone(values["username"])
    password=Common.judgeIsNone(values["password"])
    repassword=Common.judgeIsNone(values["repassword"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    Common.ifExistUsernameDelUser(self.db,self.cursor,username)
    Common.register(self.Driver, username, password, repassword)
    sqltarget=Common.getUserCount(self.db,self.cursor,username,encryptPassword)
    sqltarget = str(sqltarget)
    if target==sqltarget:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target,sqltarget)
#缺少确认密码测试
def test_04_normal_user_passwordNotInputRepassword_register(self, values,writeList,index):
    username=Common.judgeIsNone(values["username"])
    password=Common.judgeIsNone(values["password"])
    repassword=Common.judgeIsNone(values["repassword"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    Common.ifExistUsernameDelUser(self.db,self.cursor,username)
    Common.register(self.Driver, username, password, repassword)
    sqltarget=Common.getUserCount(self.db,self.cursor,username,encryptPassword)
    sqltarget=str(sqltarget)
    if target==sqltarget:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target,sqltarget)
#缺少密码和确认密码测试
def test_05_normal_user_notPasswordNotInputRepassword_register(self, values,writeList,index):
    username=Common.judgeIsNone(values["username"])
    password=Common.judgeIsNone(values["repassword"])
    repassword=Common.judgeIsNone(values["repassword"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    Common.ifExistUsernameDelUser(self.db,self.cursor,username)
    Common.register(self.Driver, username, password, repassword)
    helpBlock = self.Driver.find_elements(By.CLASS_NAME, "help-block")[1].text
    if targetConfirm==helpBlock:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetConfirm,helpBlock)

def test_01_normal_bankcard_add(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    while not Common.judgeBankCardNumIsNotExist(self.db, self.cursor, bankCardNum):
        bankCardNum = Common.generateRandomNumber(16)
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
            Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.addBankCard(self.Driver, bankCardName, bankCardNum, bankCardtype)
    balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
    bankCardCount = Common.getBankCardCount(self.db, self.cursor, userId, bankCardNum)
    bankCardCount = str(bankCardCount)
    balance = str(int(balance))
    if target == bankCardCount and balance == targetbalance:
        Common.wirteTestResult(self.work, "4", self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, "4", self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, bankCardCount)
    self.assertEqual(targetbalance, balance)
def test_02_normal_cardNum17_bankcard_add(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    while not Common.judgeBankCardNumIsNotExist(self.db, self.cursor, bankCardNum):
        bankCardNum = Common.generateRandomNumber(16)
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
            Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.addBankCard(self.Driver, bankCardName, bankCardNum, bankCardtype)
    bankCardCount = Common.getBankCardCount(self.db, self.cursor, userId, bankCardNum)
    bankCardCount = str(bankCardCount)
    if target == bankCardCount:
        Common.wirteTestResult(self.work, "5", self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, "5", self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, bankCardCount)
def test_03_normal_bankcard_again_add(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
            Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.addBankCard(self.Driver, bankCardName, bankCardNum, bankCardtype)
    bankCardCount = Common.getBankCardCount(self.db, self.cursor, userId, bankCardNum)
    bankCardCount = str(bankCardCount)
    if target == bankCardCount:
        Common.wirteTestResult(self.work, "6", self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, "6", self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, bankCardCount)
# 借记卡和信用卡卡号冲突测试

def test_04_normal_bankcard_bankCardtype_add(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
                Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.addBankCard(self.Driver, bankCardName, bankCardNum,bankCardtype)
    bankCardCount = Common.getBankCardCount(self.db,self.cursor, userId, bankCardNum)
    if target == bankCardCount:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, bankCardCount)

def test_05_normal_bankcard_del(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    Common.deleteBankByBankCardNum(self.db, self.cursor, bankCardNum)
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18),
            Common.generateRandomNumber(11),
            Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.deleteBankCard(self.Driver, bankCardNum, target)
    bankCardCount = Common.getBankCardCount(self.db, self.cursor, userId, bankCardNum)
    bankCardCount = str(bankCardCount)
    if target == bankCardCount:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser,
                               self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, bankCardCount)
def test_06_normal_bankcard_cancel_del(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
                Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    Common.deleteBankCard(self.Driver,bankCardNum,target)
    bankCardCount = Common.getBankCardCount(self.db,self.cursor, userId, bankCardNum)
    bankCardCount = str(bankCardCount)
    if target == bankCardCount :
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target,bankCardCount)


def test_07_normal_bankcard_update_bankcardName(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    rebankCardName=Common.judgeIsNone(values["rebankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    Common.deleteBankByBankCardNum(self.db,self.cursor,bankCardNum)
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
                Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    bankId=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[0]
    Common.updateBankCard(self.Driver,bankId)
    Common.updateBankCardName(self.Driver, rebankCardName)
    updatebankCardName=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[1]
    if bankCardName != updatebankCardName :
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertNotEqual(bankCardName,updatebankCardName)
def test_08_normal_bankcard_update_bankcardNum(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    rebankCardNum = Common.judgeIsNone(values["rebankCardNum"])
    if Common.judgeBankCardNumIsExist(self.db, self.cursor, rebankCardNum):
        Common.deleteBankByBankCardNum(self.db, self.cursor, rebankCardNum)
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
            Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    bankId = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[0]
    Common.updateBankCard(self.Driver, bankId)
    Common.updateBankCardNum(self.Driver, rebankCardNum)
    sqlTartget = Common.getBankCardCount(self.db, self.cursor, userId, rebankCardNum)
    sqlTartget = str(sqlTartget)
    if target == sqlTartget:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser,
                               self.posDate)

    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target, sqlTartget)
def test_09_normal_bankcard_update_bankcardNum17(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    rebankCardNum=Common.judgeIsNone(values["rebankCardNum"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
                Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    while not Common.judgeBankCardNumIsNotExist(self.db,self.cursor, rebankCardNum):
            rebankCardNum = Common.generateRandomNumber(16)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    bankId=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[0]
    Common.updateBankCard(self.Driver,bankId)
    Common.updateBankCardNum(self.Driver, rebankCardNum)
    sqlTartget=Common.getBankCardCount(self.db,self.cursor,userId,rebankCardNum)
    sqlTartget = str(sqlTartget)
    if target == sqlTartget :
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(target,sqlTartget)
def test_10_normal_bankcard_bankCardtype_update(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    rebankCardNum=Common.judgeIsNone(values["rebankCardNum"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardtype = Common.judgeIsNone(values["bankCardtype"])
    rebankCardtype = values["rebankCardtype"]
    target = Common.judgeIsNone(values["target"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
                Common.getRandomEmail(), 666666, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, 10000, 0)
    Common.getBankNumIfNotExistAddBankCard(self.db, self.cursor, userId, bankCardNum, bank)
    Common.login(self.Driver, username, password)
    Common.bankCard(self.Driver)
    bankId=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[0]
    Common.updateBankCard(self.Driver,bankId)
    Common.updateBankCardType(self.Driver, rebankCardtype)
    updatebankCardtype=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[2]
    updatebankCardtype=str(updatebankCardtype)
    if bankCardtype == updatebankCardtype:
        Common.wirteTestResult(self.work, "15", self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, "15", self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertNotEqual(bankCardtype,updatebankCardtype)


#正常买入零钱理财-支付宝零钱理财

def test_01_normal_fund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary=Common.getUser(self.db,self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd =  userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance =bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance,sqlBalance)
    isEnough=Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance=Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney=Common.getInvesMoneyByBuynid(self.db,self.cursor,buynid)
        targetbalance=str(int(balance)-int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)
# 错误支付密码-买零钱理财-支付宝零钱理财
def test_02_normal_errorPaypwd_fund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary=Common.getUser(self.db,self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance,sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 余额不足买入理财产品-支付宝零钱理财
def test_03_normal_NotEnough_fund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance,sqlBalance)
    isNotEnough = Common.checkFundMoneyNotEnough(self.db, self.cursor, bankId, balance)
    if isNotEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)
# 未绑定银行卡-买入零钱理财-支付宝零钱理财
def test_04_normal_NotBankcard_fund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    Common.deleteALLBankCardByUserId(self.db,self.cursor,userId)
    Common.login(self.Driver,username,password)
    Common.fund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element=self.Driver.find_element(By.CLASS_NAME,"jconfirm-content")
    confirm=element.text
    if targetConfirm == confirm:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetConfirm,confirm)

def test_05_normal_Timefund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.Timefund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

#错误支付密码-买期限理财-支付宝期限理财
def test_06_normal_errorPaypwd_Timefund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.Timefund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 余额不足买入期限理财-支付宝期限理财
def test_07_normal_NotEnough_Timefund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    sqlBalance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
    Common.checkBalance(self.db, self.cursor, userId, balance,sqlBalance)
    Common.login(self.Driver,username,password)
    Common.Timefund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 未绑定银行卡-买入期限理财-支付宝期限理财
def test_08_normal_NotBankcard_Timefund(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    buynid = Common.judgeIsNone(values["buynid"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    Common.deleteALLBankCardByUserId(self.db, self.cursor, userId)
    Common.login(self.Driver,username,password)
    Common.Timefund(self.Driver)
    Common.buyFund(self.Driver,buynid,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    if targetConfirm == confirm:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetConfirm, confirm)

# 正常买入基金理财-广发多元新兴股票
def test_09_normal_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver, username, password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

#错误支付密码-买基金理财-广发多元新兴股票
def test_10_normal_errorPaypwd_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 余额不足买入基金理财-广发多元新兴股票
def test_11_normal_NotEnough_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    Common.login(self.Driver,username,password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance=Common.getBankCard(self.db,self.cursor,userId,bankCardNum)[5]
    sqlBalance=str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# # 未绑定银行卡-买入基金理财-广发多元新兴股票
def test_12_normal_NotBankcard_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    Common.deleteALLBankCardByUserId(self.db, self.cursor, userId)
    Common.login(self.Driver,username,password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    if targetConfirm == confirm:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetConfirm, confirm)

# # 新银行卡没有设置密码-支付测试
def test_13_normal_notPaypwd_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    #设置密码为空
    Common.setUserPayPwd(self.db,self.cursor,userId,"")
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)[5]
    sqlBalance = str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 多个银行卡-默认支付测试
def test_14_normal_3bankcard_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    bankCardNumber = values["bankCardNumber"]
    bankCardNumber = int(bankCardNumber)
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    Common.createBankCardCount(self.db,self.cursor,userId,bankCardName,bankCardNumber)
    bankId=Common.getBankCardDefaultlByUserId(self.db,self.cursor,userId)
    sqlBalance =Common.getBankCardByBankId(self.db,self.cursor,bankId)[5]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCardByBankId(bankId)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.login(self.Driver,username,password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver,buynid,buybtnname,paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance = Common.getBankCardByBankId(self.db,self.cursor,bankId)[5]
    sqlBalance = str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 切换多个银行卡-默认支付测试
def test_15_normal_3bankcard_change_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    bankCardNumber = values["bankCardNumber"]
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    bankCardNumber=int(bankCardNumber)
    encryptPassword = Common.getEncryptPassword(self.db,self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db,self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db,self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId,  bank)
    Common.createBankCardCount(self.db,self.cursor,userId,bankCardName,bankCardNumber)
    Common.login(self.Driver,username,password)
    Common.bankCard(self.Driver)
    bankId=Common.changeBankCard(self.Driver)
    Common.fund2(self.Driver)
    sqlBalance = Common.getBankCardByBankId(self.db, self.cursor, bankId)[5]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    isEnough = Common.checkFundMoneyEnough(self.db, self.cursor, bankId, balance)
    if not isEnough:
        balance = Common.getBankCardByBankId(bankId)[5]
        payMoney = Common.getInvesMoneyByBuynid(self.db, self.cursor, buynid)
        targetbalance = str(int(balance) - int(payMoney))
    Common.buyFund2(self.Driver, buynid,buybtnname, paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlBalance = Common.getBankCardByBankId(self.db,self.cursor,bankId)[5]
    sqlBalance = str(int(sqlBalance))
    if targetbalance == sqlBalance:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, sqlBalance)

# 未绑定银行卡-买入基金理财-广发多元新兴股票
def test_16_normal_Notbankcard_fund2(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    buynid = Common.judgeIsNone(values["buynid"])
    buybtnname = Common.judgeIsNone(values["buybtnname"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = Common.judgeIsNone(values["targetbalance"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userId = Common.getUser(self.db, self.cursor, username, encryptPassword)[0]
    sqlpaypwd = Common.getUser(self.db, self.cursor, username, encryptPassword)[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    Common.deleteALLBankCardByUserId(self.db, self.cursor, userId)
    Common.login(self.Driver, username, password)
    Common.fund2(self.Driver)
    Common.buyFund2(self.Driver, buynid,buybtnname, paypwd)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    if targetConfirm == confirm:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetConfirm, confirm)

#正常申请贷款测试
def test_01_normal_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    targetLoanCount=Common.getLoanCount(self.db, self.cursor, userId)+1
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    if targetLoanCount==sqlLoanCount:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetLoanCount, sqlLoanCount)

#正常申请贷款-银行审批通过测试
def test_02_normal_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    adminUsername = values["adminUsername"]
    password = Common.judgeIsNone(values["password"])
    adminPassword = values["adminPassword"]
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    targetbalance = values["targetbalance"]
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    bankTemporary = Common.getBankCard(self.db, self.cursor, userId, bankCardNum)
    sqlBalance = bankTemporary[5]
    bankId = bankTemporary[0]
    Common.checkBalance(self.db, self.cursor, bankId, balance, sqlBalance)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    Common.exitLogin(self.Driver)
    Common.login(self.Driver, adminUsername, adminPassword)
    Common.reviewLoan(self.Driver)
    money = Common.getBankCardDefaultlByUserId2(self.db, self.cursor, userId)[5]
    if targetbalance==str(int(money)):
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetbalance, str(int(money)))
#未绑定银行卡-申请贷款
def test_03_normal_NoBankcard_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    confirm = Common.judgeIsNone(values["confirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    Common.deleteALLBankCardByUserId(self.db, self.cursor, userId)
    targetLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    if targetLoanCount==sqlLoanCount:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetLoanCount, sqlLoanCount)

#申请超大额贷款测试
def test_04_normal_AmountMoney_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    confirm = Common.judgeIsNone(values["confirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    targetLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
    confirm = element.text
    self.assertEqual(targetConfirm, confirm)
    sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    if targetLoanCount==sqlLoanCount:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
    else:
        Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
    self.assertEqual(targetLoanCount, sqlLoanCount)

#申请超小额贷款测试
def test_05_normal_smallMoney_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    confirm = Common.judgeIsNone(values["confirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    targetLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    try:
        element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
        confirm = element.text
        if targetConfirm == confirm:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
            self.assertEqual(targetConfirm, confirm)
    except:
        sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
        if targetLoanCount == sqlLoanCount:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
        self.assertEqual(targetLoanCount, sqlLoanCount)

#贷款额度-期限超期测试
def test_06_normal_Timeout_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    confirm = Common.judgeIsNone(values["confirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    targetLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    try:
        element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
        confirm = element.text
        if targetConfirm == confirm:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
        self.assertEqual(targetConfirm, confirm)
    except:
        sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
        if targetLoanCount == sqlLoanCount:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
        self.assertEqual(targetLoanCount, sqlLoanCount)

#贷款额度-期限超期测试
def test_07_normal_Timeout_user_loan(self, values,writeList,index):
    username = Common.judgeIsNone(values["username"])
    password = Common.judgeIsNone(values["password"])
    bankCardName = Common.judgeIsNone(values["bankCardName"])
    bankCardNum = Common.judgeIsNone(values["bankCardNum"])
    balance = Common.judgeIsNone(values["balance"])
    targetConfirm = Common.judgeIsNone(values["targetConfirm"])
    confirm = Common.judgeIsNone(values["confirm"])
    loanMoney = Common.judgeIsNone(values["loanMoney"])
    term = Common.judgeIsNone(values["term"])
    paypwd = Common.judgeIsNone(values["paypwd"])
    encryptPassword = Common.getEncryptPassword(self.db, self.cursor, password)
    user = (username, username, encryptPassword, Common.generateRandomNumber(18), Common.generateRandomNumber(11),
    Common.getRandomEmail(), paypwd, 0, "良好")
    Common.getUserIfNotExistAddUser(self.db, self.cursor, username, encryptPassword, user)
    userTemporary = Common.getUser(self.db, self.cursor, username, encryptPassword)
    userId = userTemporary[0]
    sqlpaypwd = userTemporary[6]
    Common.checkPayPwd(self.db, self.cursor, userId, sqlpaypwd, paypwd)
    bank = (bankCardName, "1", bankCardNum, userId, balance, "1")
    Common.getBankIfNotExistAddBankCard(self.db, self.cursor, userId, bank)
    targetLoanCount = Common.getLoanCount(self.db, self.cursor, userId)+1
    Common.login(self.Driver, username, password)
    Common.load(self.Driver)
    Common.addloan(self.Driver, loanMoney, term)
    try:
        element = self.Driver.find_element(By.CLASS_NAME, "jconfirm-content")
        confirm = element.text
        if targetConfirm == confirm:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
            self.assertEqual(targetConfirm, confirm)
    except:
        sqlLoanCount = Common.getLoanCount(self.db, self.cursor, userId)
        if targetLoanCount == sqlLoanCount:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "通过", self.posUser, self.testUser, self.posDate)
        else:
            Common.wirteTestResult(self.work, writeList[index], self.posContent, "失败", self.posUser, self.testUser, self.posDate)
        self.assertEqual(targetLoanCount, sqlLoanCount)